package com.pdstudio.actualtime;

import java.util.Arrays;

import com.pdstudio.weather.R;

import android.app.Activity;
import android.os.Bundle;
import com.pdstudio.flashview.*;

public class ActualTimeReda extends Activity {

	private ImageIndicatorView autoImageIndicatorView;

	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);

		/*
		 * 20141008改換圖片展示方式 setContentView(R.layout.actualtime_reda_main);
		 * 
		 * LayoutInflater inflater=getLayoutInflater();
		 * 
		 * //Add first page //LinearLayout myFirst = (LinearLayout)
		 * inflater.inflate( // R.layout.actualtime_circlepictures_base,
		 * null).findViewById(R.id.circlepicture_base); LinearLayout layoutMain
		 * = (LinearLayout)findViewById(R.id.reda_circlepics);
		 * layoutMain.removeAllViews(); MySurfaceView mySurfaceView = new
		 * MySurfaceView(this); layoutMain.addView(mySurfaceView); //Show the
		 * page first
		 */

		/*
		 * 20141016 改正式布局 setContentView(R.layout.actualtime_reda_fragments);
		 */

		setContentView(R.layout.actualtime_reda_main1);

		this.autoImageIndicatorView = (ImageIndicatorView) findViewById(R.id.indicate_view);
		autoImageIndicatorView
				.setOnItemChangeListener(new ImageIndicatorView.OnItemChangeListener() {
					@Override
					public void onPosition(int position, int totalCount) {

					}
				});
		this.autoImageIndicatorView
				.setOnItemChangeListener(new ImageIndicatorView.OnItemChangeListener() {
					@Override
					public void onPosition(int position, int totalCount) {

					}
				});

		initView();

	}

	private void initView() {
		// final Integer[] resArray = new Integer[] { R.drawable.poster1,
		// R.drawable.poster2, R.drawable.poster3 };
		String[] res = new String[10];
		for (int i = 0; i < 10; i++) {
			res[i] = "http://113.247.234.237//Services/NewsAttachment.ashx?AttachmentID="
					+ i;
		}

		// this.autoImageIndicatorView.setupLayoutByDrawable(resArray);
		this.autoImageIndicatorView.setupLayoutByImageUrl(Arrays.asList(res));
		this.autoImageIndicatorView.show();

		AutoPlayManager autoBrocastManager = new AutoPlayManager(
				this.autoImageIndicatorView);
		autoBrocastManager.setBroadcastEnable(true);
		autoBrocastManager.setBroadCastTimes(5);// 寰幆娆℃暟
		autoBrocastManager.setBroadcastTimeIntevel(3 * 1000, 3 * 1000);// 棣栨鍚姩鏃堕棿鍙婇棿闅�
		autoBrocastManager.loop();
	}
}
